package com.cyandpos.pad.refund.presenter;

import android.content.Context;

import com.cyandpos.pad.posdata.TicketInfo;
import com.cyandpos.pad.refund.contract.RefundContract;
import com.cyandpos.pad.refund.model.RefundModelImpl;

public class RefundPresenterImpl implements RefundContract.Presenter, RefundContract.Model.OnCompleteListener {
    private RefundContract.View mView;
    private RefundContract.Model mModel;
    private Context mContext;

    public RefundPresenterImpl(Context context, RefundContract.View view) {
        mContext = context;
        mView = view;
        mModel = new RefundModelImpl();
    }

    @Override
    public void getOldTicket(boolean isOrderNum) {
        mView.showProgress();
        if (!mView.getOldOrderNo().isEmpty() && !mView.getOldSktNo().isEmpty()){
            mModel.getOldTicketInfo(mView.getOldSktNo(),mView.getOldOrderNo(),isOrderNum,this);
        }else{
            onFailure("原订单号/原款台不能为空");
        }

    }
    @Override
    public void onSuccess(TicketInfo ticketInfo) {
        mView.dismissDialog();
        mView.onSucess(ticketInfo);
    }

    @Override
    public void onFailure(String errorMsg) {
        mView.dismissDialog();
        mView.showErrMessage(errorMsg);
    }
}
